package paidaxing.blog.core.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * MyBatis Plus 配置简化sql的字段拼接填充等
 *
 * @author heefM
 * @date 2025-10-20
 */
@Configuration
@MapperScan(basePackages = {
    "paidaxing.blog.**.mapper",
    "paidaxing.blog.common.annotation.log"
})
public class MybatisPlusConfig {

    /**
     * 分页插件---这个插件会自动添加分页参数-->sql不在需要手动写limit
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }


//    /**
//     * 元数据填充插件（自动填充创建时间、更新时间等）
//     */
//    @Bean
//    public MybatisPlusMetaObjectHandler mybatisPlusMetaObjectHandler() {
//        return new MybatisPlusMetaObjectHandler();
//    }
}